package com.homework10;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class demo {
    public static void main(String[] args) throws IOException {
        List<String> objects = new ArrayList<>();
        BufferedReader bufferedReader = new BufferedReader(new FileReader("D:\\text.txt"));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("D:\\text1.txt"));
        String len=null;
        while ((len=bufferedReader.readLine())!=null){
            objects.add(len);
        }
        Collections.reverse(objects);
        for (String object : objects) {
            bufferedWriter.write(object);
            bufferedWriter.newLine();
        }
        bufferedReader.close();
        bufferedWriter.close();

    }
}
